/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ddbserver.connections;

import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;

/**
 *
 * @author Roar
 */
public class ObjectManager {

    private static ObjectManager instance = null;
    private HashMap<String, Object> objectPoll;

    public static synchronized ObjectManager getInstance() {
        if (instance == null) {
            instance = new ObjectManager();
        }
        return instance;
    }

    private ObjectManager() {
        objectPoll = new LinkedHashMap<String, Object>();
    }

    public String addObject(Object object) {
        String key = "" + (new Date()).getTime();
        objectPoll.put(key, object);
        return key;
    }

    public Object getAndRemoveObject(String key) {
        return objectPoll.remove(key);
    }

    public Object getObjcet(String key) {
        return objectPoll.get(key);
    }
}
